package edu.ynu.se.xiecheng.achitectureclass.service;

import edu.ynu.se.xiecheng.achitectureclass.common.service.LogicService;
import edu.ynu.se.xiecheng.achitectureclass.dao.ItemDao;
import edu.ynu.se.xiecheng.achitectureclass.dao.ShopDao;
import edu.ynu.se.xiecheng.achitectureclass.dao.ShopItemDao;
import edu.ynu.se.xiecheng.achitectureclass.entity.Item;
import edu.ynu.se.xiecheng.achitectureclass.entity.Shop;
import edu.ynu.se.xiecheng.achitectureclass.entity.ShopItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


@Service
public class ShopItemService extends LogicService<ShopItemDao, ShopItem,Long> {
    @Resource
    private ShopDao shopDao;
    @Resource
    private ItemDao itemDao;
    public ShopItemService(@Autowired ShopItemDao dao) {
        super(dao);
    }

    public Double getPrice(Long shopId, Long itemId) {
        Shop shop = shopDao.getReferenceById(shopId);
        Item item = itemDao.getReferenceById(itemId);
        return getDAO().findByItemAndShop(item,shop).getPrice();
    }
}
